local db = TUNING.MOD_WEBBER_THE_TRAINER.ITEMS.staff_arachnidnexus

local function makeWeapon()
    local prefab_id = "staff_arachnidnexus"
    local assets_id = "staff_arachnidnexus"

    local assets =
    {
        Asset( "ANIM", "anim/"..assets_id..".zip"),
        Asset( "ANIM", "anim/swap_"..assets_id..".zip"),
        Asset( "ATLAS", "images/inventoryimages/"..assets_id..".xml" ),

        Asset( "ANIM", "anim/"..assets_id.."_skin_devil_trident.zip"),
        Asset( "ANIM", "anim/swap_"..assets_id.."_skin_devil_trident.zip"),
        Asset( "ATLAS", "images/inventoryimages/"..assets_id.."_skin_devil_trident.xml" ),

        Asset("ANIM","anim/when_equip_staff_show_tail.zip"),
	    Asset("ANIM","anim/when_equip_staff_show_horn.zip"),

        Asset( "ATLAS", "images/frames/merged_img_1750061074.xml" ),
    }

    local prefabs =
    {
        'fx_staff_arachnidnexus_fireballburning',
    }

    local function Turn_InvImg(tar,xml_name,total_num_of_img,step_len,time_interval)
        step_len = step_len >= 1 and step_len or 1
        if tar.equip_changeimg_task == nil then
            tar.name_num = 1
            tar.inv_image_bg = {image = '1.tex',atlas = 'images/frames/'..xml_name..'.xml'}
            tar.equip_changeimg_task = tar:DoPeriodicTask(time_interval or 0.04,function(inst)
                tar.name_num = (tar.name_num-1+step_len)%total_num_of_img+1
                tar.inv_image_bg.image = tostring(tar.name_num)..'.tex'
                tar:PushEvent("imagechange")
            end)
        end
    end
    ---comment
    ---@param player ent
    ---@param data event_data_working
    local function onworking(player,data)
        local tar = data and data.target
        ---@type ent
        local staff = player._refer_staff_arachnidnexus
        if tar and tar:HasTag('tree') and staff and staff:IsValid() and staff.components.staff_arachnidnexus_bind then
            local childs = staff.components.staff_arachnidnexus_bind:GetChildren()
            ---@cast childs ent_webbert_skitter[]
            if childs then
                for _,v in pairs(childs) do
                    if v:IsValid() and v.components.webbert_skitter_misc and (not v.components.webbert_skitter_misc:HasTempMaster() or v.components.webbert_skitter_misc:GetTempMaster() == player) then
                        local task_time = 10
                        v.components.webbert_skitter_misc._task_tree = task_time

                        SUGAR_webber_the_trainer:taskDoInTime(v,'task_intime_cancel_chop',task_time,function ()
                            if v and v:IsValid() then
                                v.components.webbert_skitter_misc._task_tree = nil
                            end
                        end,true)
                    end
                end
            end
        end

        if tar and tar:HasTag('boulder') and staff and staff:IsValid() and staff.components.staff_arachnidnexus_bind then
            local childs = staff.components.staff_arachnidnexus_bind:GetChildren()
            ---@cast childs ent_webbert_skitter[]
            if childs then
                for _,v in pairs(childs) do
                    if v:IsValid() and v.components.webbert_skitter_misc and (not v.components.webbert_skitter_misc:HasTempMaster() or v.components.webbert_skitter_misc:GetTempMaster() == player) then
                        local task_time = 10
                        v.components.webbert_skitter_misc._task_mine = task_time

                        SUGAR_webber_the_trainer:taskDoInTime(v,'task_intime_cancel_chop',task_time,function ()
                            if v and v:IsValid() then
                                v.components.webbert_skitter_misc._task_mine = nil
                            end
                        end,true)
                    end
                end
            end
        end
    end

    ---作为近战还是远程武器
    ---@param inst ent
    ---@param owner ent|nil
    local function ToBeMeleeOrRanged(inst,owner)
        if owner and owner.prefab == 'webbert' then
            inst:AddOrRemoveTag('rangedweapon', true)
            inst.components.weapon:SetRange(8,10)
            inst.components.weapon:SetProjectile("staff_arachnidnexus_projectile_fx")
            inst.components.equippable.walkspeedmult = db.webbert_walkspeedmult
        else
            inst:AddOrRemoveTag('rangedweapon', false)
            inst.components.weapon:SetRange(1,2)
            inst.components.weapon:SetProjectile(nil)
            inst.components.equippable.walkspeedmult = 1
        end
    end

    ---onequipfn
    ---@param inst ent
    ---@param owner ent
    ---@param from_ground boolean
    local function onequip(inst, owner,from_ground)
        local skin_build = inst:GetSkinBuild()
        if skin_build ~= nil then
            owner:PushEvent("equipskinneditem", inst:GetSkinName())
            owner.AnimState:OverrideItemSkinSymbol("swap_object", "swap_"..skin_build, "swap_"..skin_build, inst.GUID, "swap_"..assets_id)
        else
            owner.AnimState:OverrideSymbol("swap_object", "swap_"..assets_id, "swap_"..assets_id)
        end
        owner.AnimState:Show("ARM_carry")
        owner.AnimState:Hide("ARM_normal")

        if skin_build ~= nil then
            if skin_build == 'staff_arachnidnexus_skin_devil_trident' then
                local fx = SUGAR_webber_the_trainer:addEntRefer(inst,'owner_staff_arachnidnexus_skin_devil_trident_fx',SpawnPrefab('fx_staff_arachnidnexus_fireballburning'),true)
                local scale = .43
                fx.Transform:SetScale(scale,scale,scale)
                fx.AnimState:SetMultColour(1,1,1,.6)
                fx.entity:AddFollower()
                fx.Follower:FollowSymbol(owner.GUID, "swap_object", 10,-270,0,false)

                if owner:HasTag('player') then
                    owner.AnimState:SetSymbolAddColour('face',1,.1,.1,1)
                    owner.AnimState:SetSymbolLightOverride('face',1)

                    owner.AnimState:OverrideSymbol('tail','when_equip_staff_show_tail','tail')
                    owner.AnimState:OverrideSymbol("swap_hat", 'when_equip_staff_show_horn', "swap_hat")
                    owner.AnimState:Show("HAT")
                    owner.AnimState:Show("HAIR_HAT")

                    owner.AnimState:Show("HEAD_HAT")
                    owner.AnimState:Show("HEAD_HAT_NOHELM")
                end

                -- inst.Light:SetColour(1,1,1)
                local light = SUGAR_webber_the_trainer:addEntRefer(inst,'staff_arachnidnexus_equip_light',SpawnPrefab('staff_arachnidnexus_light_white'),true)
                light.entity:SetParent(owner.entity)
            end
        else
            -- inst.Light:SetColour(199/255, 119/255, 214/255)
            local light = SUGAR_webber_the_trainer:addEntRefer(inst,'staff_arachnidnexus_equip_light',SpawnPrefab('staff_arachnidnexus_light'),true)
            light.entity:SetParent(owner.entity)
        end
        ToBeMeleeOrRanged(inst, owner)
        -- inst.Light:Enable(true)

        -- owner._refer_staff_arachnidnexus = inst
        -- owner:ListenForEvent('working',onworking)
    end

    ---onunequipfn
    ---@param inst ent
    ---@param owner ent
    local function onunequip(inst, owner)
        owner.AnimState:Hide("ARM_carry")
        owner.AnimState:Show("ARM_normal")

        local skin_build = inst:GetSkinBuild()
        if skin_build ~= nil then
            owner:PushEvent("unequipskinneditem", inst:GetSkinName())
        end
        SUGAR_webber_the_trainer:removeEntRefer(inst,'staff_arachnidnexus_equip_light')
        SUGAR_webber_the_trainer:removeEntRefer(inst,'owner_staff_arachnidnexus_skin_devil_trident_fx')
        if owner:HasTag('player') then
            owner.AnimState:SetSymbolAddColour('face',0,0,0,0)
            owner.AnimState:SetSymbolLightOverride('face',0)

            owner.AnimState:ClearOverrideSymbol('tail')
            owner.AnimState:ClearOverrideSymbol("swap_hat")
        end

        ToBeMeleeOrRanged(inst, nil)
        -- inst.Light:Enable(false)

        -- owner._refer_staff_arachnidnexus = nil
        -- owner:RemoveEventCallback('working',onworking)
    end

    local function onfinished(inst)
        inst:Remove()
    end

    ---onattack
    ---@param inst ent
    ---@param attacker ent
    ---@param target ent
    local function onattack(inst,attacker,target)
    end

    local function fn()
        local inst = CreateEntity()

        inst.entity:AddTransform()
        inst.entity:AddAnimState()
        inst.entity:AddLight()
        inst.entity:AddMiniMapEntity()
        inst.entity:AddNetwork()
        inst.entity:AddSoundEmitter()
        MakeInventoryPhysics(inst)

        inst.AnimState:SetBank(assets_id)
        inst.AnimState:SetBuild(assets_id)
        inst.AnimState:PlayAnimation("idle",true)

        MakeInventoryFloatable(inst, "med", nil, 0.75)

        inst.Light:SetFalloff(0.7)
        inst.Light:SetIntensity(.8)
        inst.Light:SetRadius(1.8)
        inst.Light:SetColour(199/255, 119/255, 214/255)
        inst.Light:Enable(false)

        inst.entity:SetPristine()

        inst:AddTag("nosteal")

        inst:AddTag(prefab_id)

        inst.webbert_rt_panel = 'staff_arachnidnexus_common'
        function inst:fn_webbert_rt_panel_active(skill_num)
            for i = 1,8 do
                inst:AddOrRemoveTag('webbert_rt_panel_active_'..i,i == skill_num)
            end
        end
        -- inst.MiniMapEntity:SetIcon(prefab_id..".tex")

        if not TheWorld.ismastersim then
            return inst
        end

        -- inst:AddComponent("talker")
        inst:AddComponent("inspectable")

        inst:AddComponent("inventoryitem")
        inst.components.inventoryitem.imagename = assets_id
        inst.components.inventoryitem.atlasname = "images/inventoryimages/"..assets_id..".xml"
        inst.components.inventoryitem:SetOnDroppedFn(function()
            inst.Light:Enable(true)
        end)
        inst.components.inventoryitem:SetOnPutInInventoryFn(function (this, owner)
            inst.Light:Enable(false)
        end)

        inst:AddComponent("equippable")
        inst.components.equippable:SetOnEquip(onequip)
        inst.components.equippable:SetOnUnequip(onunequip)

        -- inst.components.equippable.walkspeedmult = 1.2
        -- inst.components.equippable.dapperness = 2

        inst:AddComponent("staff_arachnidnexus_skill_healaccel")

        inst:AddComponent("weapon")
        inst.components.weapon:SetDamage(db.dmg)
        -- inst.components.weapon:SetOnProjectileLaunch(function (this, attacker, target)
        --     if inst and inst.SoundEmitter then
        --         inst.SoundEmitter:PlaySound('webbert_staff_soundfx/hitfx/hit'..math.random(1,3), nil, 0.2)
        --     end
        -- end)
        -- inst.components.weapon:SetOnAttack(onattack)

        inst:AddComponent('tool')
        inst.components.tool:SetAction(ACTIONS.CHOP,1)
        inst.components.tool:SetAction(ACTIONS.MINE,1)
        -- 整齐移植
        inst:AddComponent('webbert_transplant')

        -- 绑定小宠物
        inst:AddComponent('staff_arachnidnexus_bind')
        inst.components.staff_arachnidnexus_bind:InitMaster(prefab_id)

        inst:AddComponent('staff_arachnidnexus_command')

        -- Turn_InvImg(inst,'merged_img_1750061074',24,1,FRAMES)
        Turn_InvImg(inst,'merged_img_1750061493',96,1,FRAMES)
        -- inst:AddComponent("finiteuses")
        -- inst.components.finiteuses:SetMaxUses(500)
        -- inst.components.finiteuses:SetUses(500)
        -- inst.components.finiteuses:SetOnFinished(onfinished)

        -- inst:AddComponent("rechargeable")
        -- inst.components.rechargeable:SetChargeTime(100)
        -- -- inst.components.rechargeable:SetOnDischargedFn(function(inst)  end)
        -- inst.components.rechargeable:SetOnChargedFn(function(inst)
        --     if inst:HasTag(prefab_id..'_iscd') then
        --         inst:RemoveTag(prefab_id..'_iscd')
        --     end
        -- end)

        -- local planardamage = inst:AddComponent("planardamage")
        -- planardamage:SetBaseDamage(data_prefab.planardamage)

        -- inst.OnSave = onsave
        -- inst.OnPreLoad = onpreload

        return inst
    end

    return Prefab("common/inventory/"..prefab_id, fn, assets, prefabs)
end


local function makeProj()
    local _assets =
    {
        Asset("ANIM", "anim/brilliance_projectile_fx.zip"),
        Asset("ANIM", "anim/fireball_2_fx.zip"),
        Asset("ANIM", "anim/deer_fire_charge.zip"),
    }

    local _prefabs =
    {
        "staff_arachnidnexus_projectile_blast_fx",
    }

    local SPEED = 15
    local BOUNCE_RANGE = 12
    local BOUNCE_SPEED = 10

    local function PlayAnimAndRemove(inst, anim)
        inst.AnimState:PlayAnimation(anim)
        if not inst.removing then
            inst.removing = true
            inst:ListenForEvent("animover", inst.Remove)
        end
    end

    -- local function OnThrown(inst, owner, target, attacker)
    --     inst.owner = owner
    --     if inst.bounces == nil then
    --         local hat = attacker ~= nil and attacker.components.inventory ~= nil and attacker.components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD) or nil
    --         inst.bounces = hat ~= nil and hat.prefab == "lunarplanthat" and TUNING.STAFF_LUNARPLANT_SETBONUS_BOUNCES or TUNING.STAFF_LUNARPLANT_BOUNCES
    --         inst.initial_hostile = target ~= nil and target:IsValid() and target:HasTag("hostile")
    --     end
    --     if owner and owner.prefab == 'staff_arachnidnexus' and owner.components.finiteuses then
    --         owner.components.finiteuses:Use(1)
    --     end
    -- end

    local function OnHit(inst, attacker, target)
        local skin = inst and inst.owner and inst.owner:GetSkinBuild() or nil

        local new_fx = SpawnPrefab('fireball_hit_fx')

        local blast = SpawnPrefab("staff_arachnidnexus_projectile_blast_fx")
        if skin ~= nil then
            if skin == 'staff_arachnidnexus_skin_devil_trident' then
                new_fx.AnimState:SetAddColour(.1,.1,.1,.7)
                new_fx.AnimState:SetMultColour(1,1,1,.9)

                blast.AnimState:SetAddColour(.1,.1,.1,.7)
                blast.AnimState:SetMultColour(1,1,1,.9)
            end
        end
        local x, y, z
        if target:IsValid() then
            local radius = target:GetPhysicsRadius(0) + .2
            local angle = (inst.Transform:GetRotation() + 180) * DEGREES
            x, y, z = target.Transform:GetWorldPosition()
            x = x + math.cos(angle) * radius + GetRandomMinMax(-.2, .2)
            y = GetRandomMinMax(.1, .3)
            z = z - math.sin(angle) * radius + GetRandomMinMax(-.2, .2)
            blast:PushFlash(target)
        else
            x, y, z = inst.Transform:GetWorldPosition()
        end
        blast.Transform:SetPosition(x, y, z)
        new_fx.Transform:SetPosition(x, y, z)

        inst:Remove()


    end

    local function OnMiss(inst, attacker, target)
        if not inst.AnimState:IsCurrentAnimation("disappear") then
            PlayAnimAndRemove(inst, "disappear")
        end
    end

    local function CreateTail(bank, build, lightoverride, addcolour, multcolour,owner_skin)
        local inst = CreateEntity()

        inst:AddTag("FX")
        inst:AddTag("NOCLICK")
        --[[Non-networked entity]]
        inst.entity:SetCanSleep(false)
        inst.persists = false

        inst.entity:AddTransform()
        inst.entity:AddAnimState()

        MakeInventoryPhysics(inst)
        inst.Physics:ClearCollisionMask()

        inst.AnimState:SetBank(bank)
        inst.AnimState:SetBuild(build)
        inst.AnimState:PlayAnimation("disappear")
        if owner_skin ~= nil then
            if owner_skin == 'staff_arachnidnexus_skin_devil_trident' then
                inst.AnimState:SetAddColour(.05,.05,.05,.6)
                inst.AnimState:SetMultColour(.05,.05,.05,.6)
                -- inst.AnimState:SetMultColour(20/255,250/255,112/255,1)
            end
        else
            -- inst.AnimState:SetAddColour(184/255,41/255,251/255,1)
            -- inst.AnimState:SetMultColour(147/255,82/255,203/255,1)
        end

        if lightoverride > 0 then
            -- inst.AnimState:SetLightOverride(lightoverride)
        end
        inst.AnimState:SetFinalOffset(3)

        inst:ListenForEvent("animover", inst.Remove)

        return inst
    end

    local function OnUpdateProjectileTail(inst, bank, build, speed, lightoverride, addcolour, multcolour, hitfx, tails)
        local x, y, z = inst.Transform:GetWorldPosition()
        for tail, _ in pairs(tails) do
            tail:ForceFacePoint(x, y, z)
        end
        if inst.entity:IsVisible() then
            local skin_build = inst.owner and inst.owner:GetSkinBuild()
            local tail = CreateTail(bank, build, lightoverride, addcolour, multcolour,skin_build)
            local rot = inst.Transform:GetRotation()
            tail.Transform:SetRotation(rot)
            rot = rot * DEGREES
            local offsangle = math.random() * TWOPI
            local offsradius = math.random() * .2 + .2
            local hoffset = math.cos(offsangle) * offsradius
            local voffset = math.sin(offsangle) * offsradius
            tail.Transform:SetPosition(x + math.sin(rot) * hoffset, y + voffset, z + math.cos(rot) * hoffset)
            tail.Physics:SetMotorVel(speed * (.2 + math.random() * .3), 0, 0)
            tails[tail] = true
            inst:ListenForEvent("onremove", function(tail) tails[tail] = nil end, tail)
            tail:ListenForEvent("onremove", function(inst)
                tail.Transform:SetRotation(tail.Transform:GetRotation() + math.random() * 30 - 15)
            end, inst)
        end
    end

    local function fn()
        local inst = CreateEntity()

        inst.entity:AddTransform()
        inst.entity:AddAnimState()
        inst.entity:AddPhysics()
        inst.entity:AddNetwork()

        MakeInventoryPhysics(inst)
        RemovePhysicsColliders(inst)

        inst:AddTag("FX")
        inst:AddTag("NOCLICK")

        -- inst.AnimState:SetBank("brilliance_projectile_fx")
        -- inst.AnimState:SetBuild("brilliance_projectile_fx")
        -- inst.AnimState:PlayAnimation("idle_loop", true)
        inst.AnimState:SetBank('fireball_fx')
        inst.AnimState:SetBuild('fireball_2_fx')
        inst.AnimState:PlayAnimation("idle_loop", true)

        -- inst.AnimState:SetSymbolMultColour("light_bar", 1, 1, 1, .5)
        -- inst.AnimState:SetSymbolBloom("light_bar")
        -- --inst.AnimState:SetSymbolBloom("pb_energy_loop")
        -- inst.AnimState:SetSymbolBloom("glow")
        -- --inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
        -- inst.AnimState:SetLightOverride(.5)

        --projectile (from projectile component) added to pristine state for optimization
        inst:AddTag("projectile")

        -- inst.AnimState:SetAddColour(184/255,41/255,251/255,1)
        -- inst.AnimState:SetMultColour(184/255,41/255,251/255,1)

        if not TheNet:IsDedicated() then
            inst:DoPeriodicTask(0, OnUpdateProjectileTail, nil, 'fireball_fx', 'fireball_2_fx', 15, 1, nil, nil, 'fireball_hit_fx', {})
        end

        inst.entity:SetPristine()

        if not TheWorld.ismastersim then
            return inst
        end

        inst:AddComponent("projectile")
        inst.components.projectile:SetSpeed(26)
        inst.components.projectile:SetRange(25)
        inst.components.projectile:SetOnThrownFn(function (inst, owner, target, attacker)
            inst.owner = owner
            -- if inst.bounces == nil then
            --     local hat = attacker ~= nil and attacker.components.inventory ~= nil and attacker.components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD) or nil
            --     inst.bounces = hat ~= nil and hat.prefab == "lunarplanthat" and TUNING.STAFF_LUNARPLANT_SETBONUS_BOUNCES or TUNING.STAFF_LUNARPLANT_BOUNCES
            --     inst.initial_hostile = target ~= nil and target:IsValid() and target:HasTag("hostile")
            -- end
            if owner and owner.prefab == 'staff_arachnidnexus' then
                local skin_build = owner:GetSkinBuild()
                if skin_build ~= nil then
                    if skin_build == 'staff_arachnidnexus_skin_devil_trident' then
                        inst.AnimState:SetAddColour(.02,.02,.02,.9)
                        inst.AnimState:SetMultColour(.02,.02,.02,.9)
                        -- inst.AnimState:SetMultColour(20/255,250/255,112/255,1)
                    end
                end
            end
            -- if owner and owner.SoundEmitter then
            --     owner.SoundEmitter:PlaySound('webbert_staff_soundfx/hitfx/hit'..math.random(1,3), nil, 0.2)
            -- end
        end)
        -- inst.components.projectile:SetOnPreHitFn(function (inst, attacker, target)
        --     if target then
        --         target._riftmaker_dont_drain = true
        --     end
        -- end)
        inst.components.projectile:SetOnHitFn(OnHit)
        inst.components.projectile:SetOnMissFn(OnMiss)

        inst.persists = false

        return inst
    end

    --------------------------------------------------------------------------

    local function PushColour(inst, r, g, b)
        if inst.target:IsValid() then
            if inst.target.components.colouradder == nil then
                inst.target:AddComponent("colouradder")
            end
            inst.target.components.colouradder:PushColour(inst, r, g, b, 0)
        end
    end

    local function PopColour(inst)
        inst.OnRemoveEntity = nil
        if inst.target.components.colouradder ~= nil and inst.target:IsValid() then
            inst.target.components.colouradder:PopColour(inst)
        end
    end

    local function PushFlash(inst, target)
        -- inst.target = target
        -- PushColour(inst, .1, .1, .1)
        -- inst:DoTaskInTime(4 * FRAMES, PushColour, .075, .075, .075)
        -- inst:DoTaskInTime(7 * FRAMES, PushColour, .05, .05, .05)
        -- inst:DoTaskInTime(9 * FRAMES, PushColour, .025, .025, .025)
        -- inst:DoTaskInTime(10 * FRAMES, PopColour)
        -- inst.OnRemoveEntity = PopColour
    end

    local function blastfn()
        local inst = CreateEntity()

        inst.entity:AddTransform()
        inst.entity:AddAnimState()
        inst.entity:AddNetwork()

        inst:AddTag("FX")
        inst:AddTag("NOCLICK")

        inst.AnimState:SetBank("brilliance_projectile_fx")
        inst.AnimState:SetBuild("brilliance_projectile_fx")
        inst.AnimState:PlayAnimation("blast1")
        inst.AnimState:SetSymbolMultColour("light_bar", 1, 1, 1, .5)
        inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh")
        inst.AnimState:SetLightOverride(.5)

        inst.entity:SetPristine()
        if not TheWorld.ismastersim then
            return inst
        end

        if math.random() < 0.5 then
            inst.AnimState:PlayAnimation("blast2")
        end

        inst:ListenForEvent("animover", inst.Remove)
        inst.persists = false

        inst.PushFlash = PushFlash

        return inst
    end

    return Prefab("staff_arachnidnexus_projectile_fx", fn, _assets, _prefabs),
    Prefab("staff_arachnidnexus_projectile_blast_fx", blastfn, _assets)
end
local function makeLights()
    local function fn(r,g,b)
        return function()
            local inst = CreateEntity()

            inst.entity:AddTransform()
            inst.entity:AddLight()
            inst.entity:AddSoundEmitter()
            inst.entity:AddNetwork()

            inst:AddTag("FX")
            inst:AddTag("NOCLICK")
            inst:AddTag('NOBLOCK')

            inst.Light:SetFalloff(0.7)
            inst.Light:SetIntensity(.8)
            inst.Light:SetRadius(1.8)
            inst.Light:SetColour(r,g,b)
            inst.Light:Enable(true)
            inst.entity:SetPristine()

            if not TheWorld.ismastersim then
                return inst
            end

            inst.persists = false

            return inst
        end
    end
    return Prefab("staff_arachnidnexus_light",fn(199/255, 119/255, 214/255)),
    Prefab("staff_arachnidnexus_light_white",fn(1,1,1))
end

local res = {}
for _,v in pairs({makeWeapon()}) do
    table.insert(res,v)
end
for _,v in pairs({makeProj()}) do
    table.insert(res,v)
end
for _,v in pairs({makeLights()}) do
    table.insert(res,v)
end

return unpack(res)